﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Channels.aspx.cs" Inherits="WebApp1.AdminSection.Channels" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<script src="../Content/js/jQuery.js" type="text/javascript"></script>
<script src="../Content/js/bootstrap.js" type="text/javascript"></script>
<link href="../Content/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="../Content/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />

<body>

<% NewsMine.DomainObjects.Channel ch = new NewsMine.DomainObjects.Channel(); %>

    <form id="form1" runat="server" style="margin:40px;width:500px;border:1px solid grey;padding:20px;">
   <h2>Channel Creation </h2>
    <table style="margin:0px;">
  
  <%

      string template = " <tr><td> Name</td><td><input class=\"span3 pull-right\" type=\"text\" name=\"Name\" id=\"Name\" runat=server placeholder=\"Name\" value=\"{Name}\"/> </td></tr>" +
    "<tr><td> DisplayName</td><td><input class=\"span3 pull-right\" type=\"text\" name=\"DisplayName\" id=\"DisplayName\" placeholder=\"DisplayName\" value=\"{DisplayName}\"/></td></tr>" +
   " <tr><td> Description</td><td><input class=\"span3 pull-right\" type=\"text\" name=\"Description\" id=\"Description\" placeholder=\"Description\" value=\"{Description}\"/></td></tr>" +
   " <tr><td> Language</td><td><input class=\"span3 pull-right\" type=\"text\" name=\"Language\" id=\"Language\" placeholder=\"Language\" value=\"{Language}\"/></td></tr>" +
    "<tr><td> ParentChannelName</td><td><input class=\"span3 pull-right\" type=\"text\" name=\"ParentChannelName\" id=\"ParentChannelName\" placeholder=\"ParentChannelName\" value=\"{ParentChannelName}\"/></td></tr>" +
    "<tr><td> Rank</td><td><input class=\"span3 pull-right\" type=\"text\" name=\"Rank\" id=\"Rank\" placeholder=\"Rank\" value=\"{Rank}\"/></td></tr>" +


"<tr><td> Query</td><td><textarea class=\"pull-right\" name=\"Query\" id=\"Query\" placeholder=\"Query\" >{Query}</textarea></td></tr>" +
"<tr><td> Domains</td><td><textarea class=\"pull-right\" name=\"Domains\" id=\"Domains\" placeholder=\"Domains\">{Domains}</textarea></td></tr>" +
"<tr><td> Categories</td><td><textarea class=\"pull-right\" name=\"Categories\" id=\"Categories\" placeholder=\"Categories\">{Categories}</textarea></td></tr>" +
"<tr><td> Tags</td><td><textarea class=\"pull-right\" name=\"Tags\" id=\"Tags\" placeholder=\"Tags\">{Tags}</textarea></td></tr> ";

      template = template.Replace("{Name}", this.CurrentChannel.Name)
          .Replace("{DisplayName}", this.CurrentChannel.DisplayName)
          .Replace("{Description}", this.CurrentChannel.Description)
          .Replace("{Language}", this.CurrentChannel.Language)
          .Replace("{ParentChannelName}", this.CurrentChannel.ParentChannelName)
          .Replace("{Rank}", this.CurrentChannel.Rank.ToString())
          .Replace("{Query}", this.CurrentChannel.Query)
          .Replace("{Domains}", this.CurrentChannel.Domains)
          .Replace("{Categories}", this.CurrentChannel.Categories)
          .Replace("{Tags}", this.CurrentChannel.Tags);


 Response.Write(template);

    %>
      </table>

<%--      ch.Name = "";
                ch.DisplayName = "";
                ch.Description = "";
                ch.Language = "";
                ch.ParentChannelName = "";
                ch.Rank = 0;

                ch.Query = "";
                ch.Domains = "";
                ch.Categories = "";
                ch.Tags = "";
                
                --%>

    <div class="form-actions">
  <button type="submit" class="btn btn-primary">Save changes</button>
  <button type="reset" class="btn">Cancel</button>
</div>
    </form>

    <div>
    <%
        Response.Write("hello");
        NewsMine.DataManagers.ChannelManager channelManager = new NewsMine.DataManagers.ChannelManager();

        var allChannels = channelManager.GetAllChannels();

        foreach (var item in allChannels)
        {
            Response.Write("<a href='?name=" + item.Name + "'>" + item.DisplayName + "</a><br/>");
        }
        
         %>
    </div>

    <div>
    
    <%
        
        var menus = NewsMine.DataManagers.WebSiteInfoManager.GetAllMenuItems();


        menus = (from m in menus
                 orderby m.Title
                 select m).ToList();

        List<string> menuTitles = new List<string>();

        foreach (NewsMine.DomainObjects.WebSiteMenu m in menus)
        {
            if (menuTitles.Contains(m.Title.Trim()) == false)
            {
                menuTitles.Add(m.Title.Trim());
            }
        }

        //foreach (var item in menuTitles)
        //{
        //    Response.Write("<a class=\"btn\">" + item + "</a>");
        //}

        
         %>


    </div>
</body>
</html>
